package com.neiquan.weiguan.widget;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * 作者 : hjb
 * 时间 : 2016/6/15.
 */
public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
    private int space;

    public SpacesItemDecoration(int space) {
        this.space=space;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        outRect.bottom=space;
        if(parent.getChildAdapterPosition(view)%2==1){
            outRect.right=space/2;//左边的啊
            outRect.left=space;//
        }else {

            outRect.left=space/2;//右边的啊
            outRect.right=space;
        }
        //AppLog.e("parent.getChildAdapterPosition(view)"+parent.getChildAdapterPosition(view));
    }
}
